home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / graphics / qrt.lzh / RESIZE.C < prev    next >
C/C++ Source or Header  |  1989-02-16  |  3KB  |  142 lines

  1.  
  2. /**********************************************************
  3.  
  4.       Routines to resize primitives by mx, my, mz
  5.       (used for user defined primitive types).  The
  6.       routines must also scale the position vector by
  7.       that amount.  The scale factors are passed in as
  8.       a vector (mult).
  9.  
  10.  **********************************************************/
  11.  
  12. #include "qrt.h"
  13.  
  14. /* #define RESIZEDEBUG TRUE */
  15.  
  16.  
  17. /**********************************************************
  18.  
  19.    Resizes sphere.  If !(mult.x==mult.y==mult.z) will resize
  20.    by smallest amount.
  21.  
  22.  **********************************************************/
  23.  
  24. Resize_Sphere(obj,mult)
  25.   OBJ_PTR obj;
  26.   VECT_PTR mult;
  27. {
  28.   float size;
  29.  
  30. # ifdef ROBUST
  31.     if (obj->type!=SPHERE) Error(INTERNAL_ERROR,1401);
  32. # endif
  33.  
  34.   size = MIN(MIN(mult->x,mult->y),mult->z);
  35.  
  36.   VectorMult(&(obj->loc),&(obj->loc),mult);
  37.   obj->vect1.x *= size;
  38.  
  39. # ifdef RESIZEDEBUG
  40.     printf("RESIZESPHERE: newloc = %f %f %f\n",
  41.            obj->loc.x,
  42.            obj->loc.y,
  43.            obj->loc.z);
  44.     printf("   new rad = %f\n",obj->vect1.x);
  45. # endif
  46.  
  47. }
  48.  
  49.  
  50. /**********************************************************
  51.  
  52.                  Resizes Planar object
  53.  
  54.  **********************************************************/
  55.  
  56. Resize_Plane(obj,mult)
  57.   OBJ_PTR obj;
  58.   VECT_PTR mult;
  59. {
  60.   float size;
  61.  
  62. # ifdef ROBUST
  63.     if (!((obj->type != PARALLELOGRAM) ||
  64.           (obj->type != TRIANGLE) ||
  65.           (obj->type != RING)))
  66.        Error(INTERNAL_ERROR,1402);
  67. # endif
  68.  
  69.   size = MIN(MIN(mult->x,mult->y),mult->z);
  70.  
  71.   VectorMult(&(obj->vect1),&(obj->vect1),mult);
  72.   VectorMult(&(obj->vect2),&(obj->vect2),mult);
  73.   VectorMult(&(obj->loc),  &(obj->loc),  mult);
  74.  
  75.   obj->vect3.x *= size;      /* for ring */
  76.   obj->vect3.y *= size;
  77.  
  78. # ifdef RESIZEDEBUG
  79.     printf("RESIZEPLANE: newloc = %f %f %f\n",
  80.            obj->loc.x,
  81.            obj->loc.y,
  82.            obj->loc.z);
  83. # endif
  84.  
  85. }
  86.  
  87.  
  88. /**********************************************************
  89.  
  90.                  Resizes Quadratic object
  91.  
  92.  **********************************************************/
  93.  
  94. Resize_Quadratic(obj,mult)
  95.   OBJ_PTR obj;
  96.   float mult;
  97. {
  98.  
  99. # ifdef ROBUST
  100.     if (obj->type!=QUADRATIC)
  101.        Error(INTERNAL_ERROR,1403);
  102. # endif
  103.  
  104.   VectorMult(&(obj->upper),&(obj->upper),mult);
  105.   VectorMult(&(obj->lower),&(obj->lower),mult);
  106.   VectorMult(&(obj->loc),  &(obj->loc),  mult);
  107.  
  108. # ifdef RESIZEDEBUG
  109.     printf("RESIZEQUAD: newloc = %f %f %f\n",
  110.            obj->loc.x,
  111.            obj->loc.y,
  112.            obj->loc.z);
  113. # endif
  114.  
  115. }
  116.  
  117.  
  118. /**********************************************************
  119.  
  120.     Resizes Bbox - doesn't actually do anything, since
  121.     bbox values are filled after the tree is created.
  122.  
  123.  **********************************************************/
  124.  
  125. Resize_Bbox(obj,mult)
  126.   OBJ_PTR obj;
  127.   VECT_PTR mult;
  128. {
  129.  
  130. # ifdef ROBUST
  131.     if (obj->type!=BBOX)
  132.        Error(INTERNAL_ERROR,1404);
  133. # endif
  134.  
  135. # ifdef RESIZEDEBUG
  136.     printf("RESIZEBBOX:\n");
  137. # endif
  138.  
  139. }
  140.  
  141.  
  142.